# -*- coding: utf-8 -*-
################################################################################
# Copyright (c) 2009 Renzo Sánchez-Silva
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

"""Fixture data for test suite."""

__author__ = 'Renzo Sánchez-Silva <renzo@edac.unm.edu>'
__copyright__ = '(c) 2009 University of New Mexico'
__license__ = 'Apache 2.0'
__date__ = '2009-09-23' 

from pymongo.connection import Connection

# mongoDB connection configuration.
# Change this accordingly.
db_host = 'localhost'
db_port = 27017
db_name = 'authorization_test'

connection = Connection(db_host, db_port)
db = connection[db_name]

def setUp():
    # add groups
    group_sections = {
            u'admins': [u'rms'],
            u'developers': [u'rms', u'linus'],
            u'trolls': [u'sballmer'],
            u'python': [],
            u'php': []
    }
    for k,v in group_sections.iteritems():
        db.groups.save(dict(section = k, items = v))

    # add permissions
    permission_sections = {
        u'see-site': [u'trolls'],
        u'edit-site': [u'admins', u'developers'],
        u'commit': [u'developers']
    }
    for k,v in permission_sections.iteritems():
        db.permissions.save(dict(section = k, items = v))

def tearDown():
    connection.drop_database(db)
